package com.itheima.chap01;

public class EqualsDemo {
    public static void main(String[] args) {
        Girl g1 = new Girl("小美", 18);
        Girl g2 = new Girl("小美", 18);

        System.out.println(g1 == g2);           //false

        System.out.println(g1.equals(g2));      //false  -->  true(equeal重写后)
        /*public boolean equals(Object obj) {
                return (this == obj);
            }*/
        // 因为Object类的equals方法返回的是this == obj，仍然是“==”比较，而g1和g2不相等

        System.out.println(g1.equals("小美"));   // false(重写内部的if判断条件--健壮性处理)
    }
}
